//
//  ZSMainController.m
//  微博-0C
//
//  Created by 周李波 on 16/7/19.
//  Copyright © 2016年 q. All rights reserved.
//

#import "ZSMainController.h"
#import "ZSHomeController.h"
#import "ZSMessageController.h"
#import "ZSDiscoverController.h"
#import "ZSProfileController.h"
#import "ZSTabBar.h"

@interface ZSMainController ()

@end

@implementation ZSMainController

- (void)viewDidLoad {
    [super viewDidLoad];
    //添加自定义的tabbar
    ZSTabBar *tabBar = [[ZSTabBar alloc]init];
    tabBar.composeBlock = ^{
        NSLog(@"中间按钮点击了");
    };
    [self setValue:tabBar forKey:@"tabBar"];
    
    
    //添加子视图
    [self addChildViewController:[ZSHomeController new] title:@"首页" imageName:@"tabbar_home"];
    [self addChildViewController:[ZSMessageController new] title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildViewController:[ZSDiscoverController new] title:@"发现" imageName:@"tabbar_discover"];
    [self addChildViewController:[ZSProfileController new] title:@"我" imageName:@"tabbar_profile"];
    
    
}
#pragma mark
#pragma mark - 添加子视图
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title imageName:(NSString *)imageName{
    childController.title = title;
    
    [childController.tabBarItem setImage:[[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [childController.tabBarItem setSelectedImage:[[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    //设置文字颜色
    [childController.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor orangeColor]} forState:UIControlStateSelected];
    
    [self addChildViewController:[[UINavigationController alloc]initWithRootViewController:childController]];
    
    
}


@end
